package com.dw.etl.core.service;

import com.dw.etl.common.base.mapper.BaseMapper;
import com.dw.etl.common.base.mapper.BaseMysqlMapper;
import com.dw.etl.common.base.mapper.BaseOracleMapper;
import com.dw.etl.common.util.SnowflakeIdWorker;
import com.dw.etl.common.vo.FieldAttrVO;
import com.dw.etl.common.vo.PaginationVO;
import com.dw.etl.core.api.BaseDbInfoService;
import com.dw.etl.core.api.BaseDbService;
import com.dw.etl.core.api.TableOperService;
import com.dw.etl.core.bean.model.BaseDb;
import com.dw.etl.core.db.RoutingDataSource;
import com.dw.etl.core.db.ThreadLocalDataSource;
import com.dw.etl.core.mapper.BaseDbMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * baseDbInfo服务实现类
 * Created by hozeData on 2021/05/21.
 */
@Service
public class BaseDbInfoServiceImpl implements BaseDbInfoService {

    private static final Logger LOGGER = LoggerFactory.getLogger(BaseDbInfoServiceImpl.class);

    @Autowired
    private BaseDbMapper baseDbMapper;

    @Autowired
    private TableOperService TableOperService;

    @Override
    public List<FieldAttrVO> getTables(Long idDb,String tableName) {
        BaseDb baseDb = baseDbMapper.selectByPrimaryKey(idDb);
        List<FieldAttrVO> list = TableOperService.findTables(baseDb,tableName);
        return list;
    }

    @Override
    public List<FieldAttrVO> getTableInfo(Long idDb, String tables) {
        BaseDb baseDb = baseDbMapper.selectByPrimaryKey(idDb);
        return  TableOperService.findFieldMsgFromDb(baseDb, tables);
    }
}
